Feature/세미나 출석 코드 입력 제한 + 최근의 세미나 조회 기능 구현 - #232
Hidden character warning
Conversation
| @Transactional | ||
| public SeminarAttendanceResponse save(Long seminarId, Member member, SeminarAttendanceCodeRequest request){ | ||
| public SeminarAttendanceResponse save(Long seminarId, Member member, SeminarAttendanceCodeRequest request) { | ||
| String key = "seminar:" + LocalDate.now() + "memberId:" + member.getId(); |
There was a problem hiding this comment.
오오 redis key naming convention을 사용하셨군요..! 부끄럽게도 전 redis 만질 때 저걸 몰라서 key name을 막 지었습니다 ㅎㅎ...
nit)
| String key = "seminar:" + LocalDate.now() + "memberId:" + member.getId(); | |
| String key = "seminar:" + LocalDate.now() + ":memberId:" + member.getId(); |
There was a problem hiding this comment.
그러고 보니 야구게임, 로그인 쪽에서는 _ 로 키 이름이 구분지어져 있네요! 통일성 있게 _ 로 수정하겠습니다!
There was a problem hiding this comment.
아 아니에용 @shkisme 님의 naming convention에 맞게 야구 게임쪽을 고치겠습니다~~
|
|
||
|
|
||
| @Test | ||
| @DisplayName("출석코드 5회 초과 입력 시 출석이 불가능해야 한다.") |
| .seminarAttendanceStatus(seminar.getStatus()) | ||
| .build(); | ||
| return SeminarAttendanceResponse.of(attendanceRepository.save(attendance), attemptNumber); | ||
| return SeminarAttendanceResponse.of(attendanceRepository.save(attendance)); |
There was a problem hiding this comment.
출석 시도 횟수를 응답으로 내려주지 않도록 변경한 이유가 있을까요?
There was a problem hiding this comment.
처음에는 시도 횟수를 출석 코드가 틀렸을 때 마다 반환하려고 했는데요! 출석을 성공했을 경우에만 출석 시도 횟수를 성공 응답으로 보내주게 되어서 (출석 코드를 틀렸을 경우에는 400 응답을 보내게 되니...) 필요가 없을 것 같아서 뺐습니다! 프론트에서 처리가 가능한 지 문의드렸고 확인중이라고 합니다!
이 부분 혹시 다르게 처리할 수 있는 방법이 있을까요? 🤔
| int attemptNumber = redisUtil.increaseAndGetWithExpire(key, 60 * 60).intValue(); // 1시간 후 만료 | ||
| if (attemptNumber > 5) { |
There was a problem hiding this comment.
주석을 static 변수로 표현하면 지울 수 있겠네요. (60 * 60)
5를 의미하는 static 변수도 만드는게 좋을까요..?
There was a problem hiding this comment.
MAX_ATTEMPT_COUNT 같은걸로 해도 괜찮을 것 같네요~
@hyuunnn 오랜만입니다 ㅎㅎ
| return seminarRepository.findRecentlyDoneSeminar(now) | ||
| .map(Seminar::getId) | ||
| .map(SeminarIdResponse::new) | ||
| .orElse(null); | ||
| } | ||
|
|
||
| public List<SeminarIdResponse> getRecentlyUpcomingSeminars() { | ||
| LocalDate now = LocalDate.now(); | ||
| return seminarRepository.findRecentlyUpcomingSeminar(now) | ||
| .stream() | ||
| .map(Seminar::getId) | ||
| .map(SeminarIdResponse::new) | ||
| .toList(); |
There was a problem hiding this comment.
SeminarIdResponse 클래스가 제가 만든거지만..
dto 역할을 하는, 데이터만 넘겨주는 껍데기인데
사용할 때마다 새로운 object를 new를 통해 생성하는게 과연 효율적인지에 대해 고민이 들더라구요..
자주 사용하시는 of처럼 static 메서드로 만들어서 싱글톤 패턴으로 만든다면..? 여기까지 ㅎㅎ..
There was a problem hiding this comment.
new로 만드는게 좋을 것 같아요~ 요청마다 SemiarId는 다른 값을 가지게 될텐데 싱글톤으로 만들어버리면 동시성 문제 때문에 값이 섞일 수 있을 것 같네요~
There was a problem hiding this comment.
저도 DTO, 싱글톤에 대해서 한번 더 생각해보게 되네요!
There was a problem hiding this comment.
@gusah009 아 그러네요 중간에 값이 바뀔 수가 있네요.. 잘못 생각했습니다...
다른거 공부하다 보니까 바보 멍청이가 되었습니다...
| return attemptNumber; | ||
| } | ||
|
|
||
| private void validAttendanceCode(Seminar seminar, SeminarAttendanceCodeRequest request) { |
There was a problem hiding this comment.
이 부분 혹시 다르게 처리할 수 있는 방법이 있을까요? 🤔
여기서 throw로 던져줄 때 inputAttendanceCode 대신 attemptNumber를 던져주는 방법도 있을 것 같네용~
There was a problem hiding this comment.
에러와 함께 시도횟수를 주는 방법도 있었네요! 이 방법으로 수정해보겠습니다!
- 세미나 출석은 정회원만 가능하게 구현하기 위함.
- 회원도 접근 가능하도록 - 자신의 출석 상태도 응답으로 반환하도록 (만약 출석 정보가 없을 시는 `출석 전` 상태를 반환)
- 출석 api의 HTTP 메서드를 @PatchMapping으로 변경 - 틀린 출석 코드 입력할 경우 에러 메시지와 함께 시도 횟수를 반환하도록 - 출석 정보를 찾을 수 없는 경우 에러 반환
- pathVariable로 회원 id를 받아 수정 가능하도록 - 추후 관리자용 api가 될 예정임을 TODO로 명시
|
프론트에서 얼른 테스트해봐야 할 거 같아서 여기서 작업하고 바로 머지하겠습니다! 작업요약
뭔가 상벌점 도메인이랑 엮어서 생각하니 꽤나 복잡하고 아직 기획이 안 된 부분도 있어서 일단은 더 고민해보고 추후에 작업해야 할 것 같습니다!
|
🔥 Related Issue
close: #215
close: #216
📝 Description
⭐️ Review Request
기획서
세미나 도메인 어렵네요....!